ARCH = $(shell getconf LONG_BIT)
LAN_DIR = $(shell pwd)/../lan
LAN_DIR_EXIST = $(shell if [ -d $(LAN_DIR) ]; then echo "exist"; else echo "notexist"; fi;)

ifeq ($(ARCH), 64)
XML2BIN_DIR = 64bit_xml2bin
else
XML2BIN_DIR = 32bit_xml2bin
endif

all: xml
xml: lan_dir
	-rm higv.bin
	-rm *.c *.h
	-rm xml2bin
	cp ../../../../../component/higv/tools/$(XML2BIN_DIR)/xml2bin ./
	./xml2bin -b ./higv.bin -e ./ -t c -x ./ -l ../lan
	chmod 0775 ../lan/*.lang
	cp *.bin ../../ -rf
	cp higv*.c ../../ -rf
	cp higv*.h ../../ -rf
clean:
	-rm -rf *.c *.h
	-rm higv.bin
	-rm xml2bin
	-rm ../lan/*.lang

.PHONY: lan_dir
lan_dir:
	if [ $(LAN_DIR_EXIST) = notexist ]; then  mkdir $(LAN_DIR);fi
